/**
 * @Description: 检测当前设备
 * @Version: 1.0
 * @Author: 琴时
 * @Date: 2021-11-29 23:01:04
 * @LastEditors: 琴时
 * @LastEditTime: 2021-11-29 23:56:47
 * @FilePath: \pt-utils\src\utils_html\检测设备.js
 */
/*******
 * @description: 检测移动端-PC端
 * @author: 琴时
 * @param {*} [无]
 * @return {*} [移动端:true - PC端:false]
 */
const ua = navigator.userAgent // 获取设备信息
export const isMobile = () => {
  return Boolean(
    ua.match(
      /(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i
    )
  )
}
/*******
 * @description: android终端-ios终端
 * @author: 琴时
 * @return {Boolean}
 */
export const isAndroid = () => {
  return ua.indexOf('Android') > -1 || ua.indexOf('Adr') > -1
}
export const isIOS = () => {
  return Boolean(ua.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/))
}

/*******
 * @description: 是否微信环境-QQ环境
 * @author: 琴时
 * @return {Boolean}
 */
export const isWeiXn = () => {
  return ua.toLowerCase().includes('micromessenger')
}
export const isQQ = () => {
  u.match(/\sQQ/i) == ' qq'
}

/*******
 * @description: 浏览器内核
 * @author: 琴时
 * @return {*} 返回内核信息
 */

export const kernelInfo = () => {
  return {
    trident: ua.indexOf('Trident') > -1, //IE内核
    presto: ua.indexOf('Presto') > -1, //opera内核
    webKit: ua.indexOf('AppleWebKit') > -1, //苹果、谷歌内核
    gecko: ua.indexOf('Gecko') > -1 && ua.indexOf('KHTML') == -1, //火狐内核
  }
}

/**
 * 测试用例
 * 直接无法测试，请使用npm start ==>在浏览器访问:http://127.0.0.1:3000
 */
